from PIL import Image
import os


# 将图片转成png
def convert_to_png(input_image_path, output_image_path):
    image = Image.open(input_image_path)
    if image.mode != 'RGBA':
        image = image.convert('RGBA')
    image.save(output_image_path, 'PNG')
    # 删除input_path
    os.remove(input_path)


if __name__ == '__main__':
    # 用法示例
    input_path = 'C:/Users/test/Pictures/Saved Pictures/01.jpg'
    output_path = 'C:/Users/test/Pictures/Saved Pictures/02.png'
    convert_to_png(input_path, output_path)
    print('ok')
